package preprocess;

import classification.elemListRepr.XMLElementList;

import com.db4o.ObjectContainer;

public interface DBManage
{

    /**
     * Create a new database according the DBName
     * 
     * @param DBName
     *            Specify the database name
     * @return true if create succeed, false if there is already a database of
     *         same name exist or any other error occur in create process
     */
    public ObjectContainer createDB(String DBName);

    /**
     * Insert <b> XML document </b> object into database
     * 
     * @param doc
     *            The XML document object to be inserted
     * @param DBName
     *            DBName indicate the database to be insert
     * @return true if insert succeed, false if there is already a document
     *         object of same name exist or any other error occur in insert
     *         process
     */
    public boolean insert(XMLDoc doc, String DBName);

    /**
     * Insert <b> XMLElementList </b> object into database
     * 
     * @param xmlElemList
     *            The XMLElementList object to be inserted
     * @param DBName
     *            DBName indicate the database to be insert
     * @return true if insert succeed, false if there is already a
     *         XMLElementList object of same name exist or any other error occur
     *         in insert process
     */
    public boolean insert(XMLElementList xmlElemList, String DBName);

    /**
     * Insert <b> ArrayList(XMLElementList) </b> object into database
     * 
     * @param list
     *            XMLELRList object to be insert
     * @param DBName
     *            DBName indicate the database to be insert
     * @return true if insert succeed, false if there is already a XMLELRList
     *         object of same name exist or any other error occur in insert
     *         process
     */
    public boolean insert(XMLELRList list, String DBName);

    /**
     * Get the <b> XML document </b> object by specified <b> docID </b>
     * 
     * @param DBName
     *            Specify the database to be queried
     * @param DocID
     *            The XML document ID
     * @return The XML document object according to the DocID
     */
    public XMLDoc queryXMLDoc(String DBName, String docID);

    /**
     * Get the <b> XMLElementList </b> object by specified <b> docID </b>
     * 
     * @param DBName
     *            Specify the database to be queried
     * @param listID
     *            The XMLElementList ID
     * @return The XMLElementList object according to the listID
     */
    public XMLElementList queryXMLElemList(String DBName, String listID);

    /**
     * Get the <b> XMLELRList </b> object according to specified listID
     * 
     * @param DBName
     *            Specify the database to be queried
     * @param listID
     *            The XMLELRList ID
     * @return The XMLELRList object according to the listID
     */
    public XMLELRList queryXMLELRList(String DBName, String listID);

    /**
     * Reset the DBName specified database to be empty
     * 
     * @param DBName
     *            The database which is specified to be empty
     * @return true if reset succeed, false otherwise
     */
    public boolean resetDB(String DBName);

    /**
     * Delete the DBName specified database
     * 
     * @param DBName
     *            The database to be deleted
     * @return true if delete succeed, false otherwise
     */
    public boolean deleteDB(String DBName);

    /**
     * Find out whether the database specified by <B>DBName</B> is existed
     * 
     * @param DBName
     *            The database name which to be tested
     * @return true if there is a database of the same name <B>DBName</B> is
     *         exist, false otherwise
     */
    public boolean exists(String DBName);
}
